package cn.hiapi.admin.api;

import cn.hiapi.admin.query.activity_order.AdminActivityExpandOrderQuery;
import cn.hiapi.admin.vo.activity_order.ActivityCardOrderVo;
import cn.hiapi.basic.controller.BasicQueryController;
import cn.hiapi.basic.service.BasicService;
import cn.hiapi.interfaces.DispatchContext;
import cn.hiapi.interfaces.user.IUserService;
import cn.hiapi.shopkeeper.entity.order.ActivityCardOrder;
import cn.hiapi.shopkeeper.service.order.ActivityCardOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author AdinZ
 * @date 2023/2/16 15:13
 */
@RestController
@RequestMapping("/manage/activity-order/card")
public class AdminActivityCardOrderController extends BasicQueryController<ActivityCardOrder, Long, ActivityCardOrderVo, AdminActivityExpandOrderQuery> {
    protected AdminActivityCardOrderController(ActivityCardOrderService basicService, DispatchContext dispatchContext) {
        super(basicService, dispatchContext);
    }

    @Override
    public List<ActivityCardOrderVo> toListVo(List<ActivityCardOrder> list, String[] fields) {
        return this.toList(list, fields);
    }

    @Override
    public ActivityCardOrderVo toData(ActivityCardOrder data, String[] fields) {
        ActivityCardOrderVo vo = data.copy(new ActivityCardOrderVo());
        vo.setUser(this.dispatchContext.getServiceOne(IUserService.class).fieldBase(vo.getBuyerId()));
        return vo;
    }
}
